<?php
namespace Exam\Controller;
use Common\Controller\AdminbaseController;
class AdminShitiController extends AdminbaseController {

	function _initialize() {
	  parent::_initialize();
	  $this->shiti_obj = D("ExamShiti");
	  $this->papers_obj = D("ExamPapers");
	  $this->userpapers_obj = D("ExamUserpapers");
	  $this->myerrors = D("ExamMyerrors");

	}
	
	//文章
	function post(){
		$data = M('exam_post')->where("del = '0'")->order("id desc")->select();
		$this->assign('data',$data);
		$this->display();
	}
	//添加文章
	function addpost(){
		$course = M('course')->field('id,cs_name')->order("listorder asc,id asc")->select();
		if(isset($_POST['stem'])){
			$add = M('exam_post')->add($_POST);
			if($add){
				echo 1;die;
			}else{
				echo 2;die;
			}
		}
		$this->assign('course',$course);
		$this->display();
	}
	//删除文章
	function delpost(){
		$id = I('id');
		$data['del'] = 1;
		$del = M('exam_post')->where("id = '$id'")->save($data);
		if($del){
			$this->success('删除成功！');
		}else{
			$this->error('删除失败！');
		}
	}
	//添加试卷
	function addshijuan(){
		$m = M('exam_shiti');
		$course = M('course')->field('id,cs_name')->order("listorder asc")->select();
		$shiti = array();
		if(isset($_POST['cid'])){
			$cid = I('cid');
		}
		for($i=1;$i<=11;$i++){
			if($i==1){
				$bl = 'xuanze';
			}elseif($i == 2){
				$bl = 'tiankong';
			}elseif($i == 3){
				$bl = 'panduan';
			}elseif($i == 4){
				$bl = 'wenda';
			}elseif($i == 5){
				$bl = 'cailiao';
			}elseif($i == 6){
				$bl = 'yuedulijie';
			}elseif($i == 7){
				$bl = 'duoxuan';
			}elseif($i == 8){
				$bl = 'app1';
			}elseif($i == 9){
				$bl = 'wenda1';
			}elseif($i == 10){
				$bl = 'wenda2';
			}elseif($i == 11){
				$bl = 'wenda3';
			}
			$$bl = $m->field("id,stem")->where("typeid = '$i' and cs_id = '$cid'")->order("id asc")->select();

			if($i == 6  || $i == 8){

				$$bl = $m->field("id,stem")->where("typeid = '$i' and cs_id = '$cid' and post_id != '0'")->order("id asc")->select();

				if($i == 6) { /*阅读理解*/
					$$bl = M('exam_post')->field('id,stem')->where("cid = '$cid' && solve_id ='0'")->order("id asc")->select();
				}
				if($i == 8) { /*材料问答*/
					$$bl = M('exam_post')->field('id,stem')->where("cid = '$cid' and solve_id = '1'")->order("id asc")->select();
				}
			}
			if($i == 7){
				$$bl = $m->field("id,stem")->where("typeid = '$i' and cs_id = '$cid' ")->order("id asc")->select();
			}
			$shiti["$bl"] = $$bl;
		}


		$this->assign("shiti",$shiti);
		$this->assign("course",$course);
		$this->display();
	}
	//修改试卷
	function editshijuan(){
		$id = I('id');
		$data = M('exam_papers')->where("id = '$id'")->find();

			$data['select_id'] = explode(',', $data['select_id']);
			$data['fill_id'] = explode(',', $data['fill_id']);
			$data['judge_id'] = explode(',', $data['judge_id']);
			$data['ask_id'] = explode(',', $data['ask_id']);
			$data['app_id'] = explode(',', $data['app_id']);
			$data['post_id'] = explode(',', $data['post_id']);
			$data['duoxuan_id'] = explode(',', $data['duoxuan_id']);
			$data['app1_id'] = explode(',', $data['app1_id']);
			$data['ask1_id'] = explode(',', $data['ask1_id']);
			$data['ask2_id'] = explode(',', $data['ask2_id']);
			$data['ask3_id'] = explode(',', $data['ask3_id']);

		$m = M('exam_shiti');
		$course = M('course')->field('id,cs_name')->where("1 = 1")->order("listorder asc")->select();
//		$course = M('course')->field('id,cs_name')->order("listorder asc")->select(false);

		$cid = $data['cs_id'];
		if(isset($_POST['cid'])){
			$cid = I('cid');
		}
		for($i=1;$i<=11;$i++){
			if($i==1){
				$bl = 'xuanze';
			}elseif($i == 2){
				$bl = 'tiankong';
			}elseif($i == 3){
				$bl = 'panduan';
			}elseif($i == 4){
				$bl = 'wenda';
			}elseif($i == 5){
				$bl = 'cailiao';
			}elseif($i == 6){
				$bl = 'yuedulijie';
			}elseif($i == 7){
				$bl = 'duoxuan';
			}elseif($i == 8){
				$bl = 'app1';
			}elseif($i == 9){
				$bl = 'wenda1';
			}elseif($i == 10){
				$bl = 'wenda2';
			}elseif($i == 11){
				$bl = 'wenda3';
			}

			if($i == 6){
				$$bl = M('exam_post')->field('id,stem')->where("cid = '$cid' && solve_id ='0'")->order("id asc")->select();
			}else if($i == 8){
				$$bl = M('exam_post')->field('id,stem')->where("cid = '$cid' && solve_id ='1' ")->order("id asc")->select();
			}else{
				$$bl = $m->field("id,stem")->where("typeid = '$i' and cs_id = '$cid'")->order("id asc")->select();
			}

			$shiti["$bl"] = $$bl;
		}
		$this->assign("data",$data);
		$this->assign("shiti",$shiti);
		$this->assign("course",$course);
		$this->display();
	}
	
	//预览试卷
	function seeshijuan(){
		$m = M('exam_shiti');
		$id = I('id');

		$data = M('exam_papers')->where("id = '$id'")->find();


		$data['select_id'] = explode(',', $data['select_id']);
		$data['fill_id'] = explode(',', $data['fill_id']);
		$data['judge_id'] = explode(',', $data['judge_id']);
		$data['ask_id'] = explode(',', $data['ask_id']);
		$data['app_id'] = explode(',', $data['app_id']);
		$data['post_id'] = explode(',', $data['post_id']);
		$data['duoxuan_id'] = explode(',', $data['duoxuan_id']);
		$data['app1_id'] = explode(',', $data['app1_id']);
		$data['ask1_id'] = explode(',', $data['ask1_id']);
		$data['ask2_id'] = explode(',', $data['ask2_id']);
		$data['ask3_id'] = explode(',', $data['ask3_id']);

		$data['select_n'] = number_format($data['select_num'] / count($data['select_id']),1);
		$data['fill_n'] = number_format($data['fill_num'] / count($data['fill_id']),1);
		$data['judge_n'] = number_format($data['judge_num'] / count($data['judge_id']),1);
		$data['ask_n'] = number_format($data['ask_num'] / count($data['ask_id']),1);
		$data['app_n'] = number_format($data['app_num'] / count($data['app_id']),1);
		$data['duoxuan_n'] = number_format($data['duoxuan_num'] / count($data['duoxuan_id']),1);
		$data['app1_n'] = number_format($data['app1_num'] / count($data['app1_id']),1);
		$data['ask1_n'] = number_format($data['ask1_num'] / count($data['ask1_id']),1);
		$data['ask2_n'] = number_format($data['ask2_num'] / count($data['ask2_id']),1);
		$data['ask3_n'] = number_format($data['ask3_num'] / count($data['ask3_id']),1);


		foreach($data['select_id'] as $v ){
			$select[] = $m->field('stem,xa,xb,xc,xd')->where("id = '$v'")->find();
		}
		foreach($data['fill_id'] as $v){
			$fill[] = $m->field('stem')->where("id = '$v'")->find();
		}
		foreach($data['judge_id'] as $v){
			$judge[] = $m->field('stem')->where("id = '$v'")->find();
		}
		foreach($data['ask_id'] as $v){
			$ask[] = $m->field('stem')->where("id = '$v'")->find();
		}
		foreach($data['app_id'] as $v){
			$app[] = $m->field('stem,stem_content')->where("id = '$v'")->find();
		}
		foreach($data['post_id'] as $v){
			$wen = M('exam_post')->field('stem,content')->where("id = '$v'")->find();
			$postarr = $m->field('stem,xa,xb,xc,xd')->where("post_id = '$v'")->select();
			$wen['post'] = $postarr;
			$post[] = $wen;
		}
		foreach($data['duoxuan_id'] as $v){
			$duoxuan[] = $m->field('stem,xa,xb,xc,xd')->where("id = '$v'")->find();
		}

		foreach($data['app1_id'] as $v){
			$wen = M('exam_post')->field('stem,content')->where("id = '$v'")->find();
			$app1arr = $m->field('stem')->where("post_id = '$v'")->select();
			$wen['app1'] = $app1arr;
			$app1[] = $wen;
		}
		foreach($data['ask1_id'] as $v){
			$ask1[] = $m->field('stem')->where("id = '$v'")->find();
		}
		foreach($data['ask2_id'] as $v){
			$ask2[] = $m->field('stem')->where("id = '$v'")->find();
		}
		foreach($data['ask3_id'] as $v){
			$ask3[] = $m->field('stem')->where("id = '$v'")->find();
		}


		$data['select'] = $select;
		$data['fill'] = $fill;
		$data['judge'] = $judge;
		$data['ask'] = $ask;
		$data['app'] = $app;
		$data['post'] = $post;
		$data['duoxuan'] = $duoxuan;
		$data['app1'] = $app1;
		$data['ask1'] = $ask1;
		$data['ask2'] = $ask2;
		$data['ask3'] = $ask3;
		$this->assign("data",$data);
		$this->assign("x",'1');
		$this->display();
	}
	
	
	//修改试卷
	function editshijuan_post(){
		$id = I('id');
		$data = array();
		$data['cs_id'] = I('cs_id');
		$data['limitedTime'] = I('limitedTime');
		$data['select_num'] = I('sele_num');
		$data['fill_num'] = I('fill_num');
		$data['judge_num'] = I('judge_num');
		$data['ask_num'] = I('ask_num');
		$data['app_num'] = I('app_num');
		$data['post_num'] = I('post_num');
		$data['duoxuan_num'] = I('duoxuan_num');
		$data['app1_num'] = I('app1_num');
		$data['ask1_num'] = I('ask1_num');
		$data['ask2_num'] = I('ask2_num');
		$data['ask3_num'] = I('ask3_num');

		$data['state'] = I('state');
		$data['title'] = I('title');
		
		$data['select_name'] = I('sename');
		$data['fill_name'] = I('fill_name');
		$data['judge_name'] = I('judge_name');
		$data['ask_name'] = I('ask_name');
		$data['app_name'] = I('app_name');
		$data['post_name'] = I('post_name');
		$data['duoxuan_name'] = I('duoxuan_name');
		$data['app1_name'] = I('app1_name');
		$data['ask1_name'] = I('ask1_name');
		$data['ask2_name'] = I('ask2_name');
		$data['ask3_name'] = I('ask3_name');

		$select1 = I('select1');
		$select2 = I('select2');
		$select3 = I('select3');
		$select4 = I('select4');
		$select5 = I('select5');   
		$select6 = I('select6');
		$select7 = I('select7');
		$select8 = I('select8');
		$select9 = I('select9');
		$select10 = I('select10');
		$select11 = I('select11');
		if($select1){
			$data['select_id'] = implode(',', $select1);
		}
		if($select2){
			$data['fill_id'] = implode(',', $select2);
		}
		if($select3){
			$data['judge_id'] = implode(',', $select3);
		}
		if($select4){
			$data['ask_id'] = implode(',', $select4);
		}
		if($select5){
			$data['app_id'] = implode(',', $select5);
		}
		if($select6){
			$data['post_id'] = implode(',', $select6);
		}
		if($select7){
			$data['duoxuan_id'] = implode(',', $select7);
		}
		if($select8){
			$data['app1_id'] = implode(',', $select8);
		}
		if($select9){
			$data['ask1_id'] = implode(',', $select9);
		}
		if($select10){
			$data['ask2_id'] = implode(',', $select10);
		}
		if($select11){
			$data['ask3_id'] = implode(',', $select11);
		}

		$data;
        S('exam_data',null);
		$save = M('exam_papers')->where("id = '$id'")->save($data);
		if($save){
			echo 1;
		}else{
			echo 2;
		}
	}
	function addshijuan_post(){
		$data = array();
		$data['cs_id'] = I('cs_id');
		$data['limitedTime'] = I('limitedTime');
		$data['select_num'] = I('sele_num');
		$data['fill_num'] = I('fill_num');
		$data['judge_num'] = I('judge_num');
		$data['ask_num'] = I('ask_num');
		$data['app_num'] = I('app_num');
		$data['post_num'] = I('post_num');
		$data['duoxuan_num'] = I('duoxuan_num');
		$data['app1_num'] = I('app1_num');
		$data['ask1_num'] = I('ask1_num');
		$data['ask2_num'] = I('ask2_num');
		$data['ask3_num'] = I('ask3_num');


		$data['state'] = I('state');
		$data['title'] = I('title');
		$data['addtime'] = time();
		$data['select_name'] = I('sename');
		$data['fill_name'] = I('fill_name');
		$data['judge_name'] = I('judge_name');
		$data['ask_name'] = I('ask_name');
		$data['app_name'] = I('app_name');
		$data['post_name'] = I('post_name');
		$data['duoxuan_name'] = I('duoxuan_name');
		$data['app1_name'] = I('app1_name');
		$data['ask1_name'] = I('ask1_name');
		$data['ask2_name'] = I('ask2_name');
		$data['ask3_name'] = I('ask3_name');

		$select1 = I('select1');
		$select2 = I('select2');
		$select3 = I('select3');
		$select4 = I('select4');
		$select5 = I('select5');   
		$select6 = I('select6');
		$select7 = I('select7');
		$select8 = I('select8');
		$select9 = I('select9');
		$select10 = I('select10');
		$select11 = I('select11');
		if($select1){
			$data['select_id'] = implode(',', $select1);
		}
		if($select2){
			$data['fill_id'] = implode(',', $select2);
		}
		if($select3){
			$data['judge_id'] = implode(',', $select3);
		}
		if($select4){
			$data['ask_id'] = implode(',', $select4);
		}
		if($select5){
			$data['app_id'] = implode(',', $select5);
		}
		if($select6){
			$data['post_id'] = implode(',', $select6);
		}
		if($select7){
			$data['duoxuan_id'] = implode(',', $select7);
		}
		if($select8){
			$data['app1_id'] = implode(',', $select8);
		}
		if($select9){
			$data['ask1_id'] = implode(',', $select9);
		}
		if($select10){
			$data['ask2_id'] = implode(',', $select10);
		}
		if($select11){
			$data['ask3_id'] = implode(',', $select11);
		}
		$add = M('exam_papers')->add($data);
        S('exam_data',null);
		if($add){
			echo 1;
		}else{
			echo 2;
		}
	}
	
	
	//添加试题
	function addshiti(){
		$course = M('course')->field('id,cs_name')->order("listorder asc,id asc")->select();
		if(isset($_POST['cid'])){
			$cid = I('cid');
			$post = M('exam_post')->where("cid = '$cid'")->order("id desc")->select();
		}
		$this->assign('post',$post);
		$this->assign('course',$course);
		$this->display();
	}
	function add_post(){
		if(IS_POST){
			$data = array();
			$data['typeid'] = I('typeid');
			$data['stem'] = I('stem');
			$data['xa'] = I('xA');
			$data['xb'] = I('xB');
			$data['xc'] = I('xC');
			$data['xd'] = I('xD');
			$data['post_id'] = I('post_id');
			$data['cs_id'] = I('cs_id');
			$data['stem_content'] = I('stem_content');
			if($data['typeid'] == 7){
				$daan = I('duoxuan');
				$data['daan'] = implode(' ',$daan);
			}else{
				$data['daan'] = I('daan');
			}
			$data['analysis'] = I('content');

			$add = $this->shiti_obj->add($data);
			if($add){
				echo 1;die;
			}else{
				echo 2;die;
			}
		}
	}
	function shitilist(){
		if(IS_POST){
			$typeid=  intval(I("post.typeid"));
			$where_ands=empty($typeid)?array("cs_id>0" ):array("cs_id>0 and typeid=$typeid");
			$fields=array(
				'keyword'  => array("field"=>"stem","operator"=>"like"),
		   );
			foreach ($fields as $param =>$val){
				if (isset($_POST[$param]) && !empty($_POST[$param])) {
					$operator=$val['operator'];
					$field   =$val['field'];
					$get=$_POST[$param];
					$_GET[$param]=$get;
					if($operator=="like"){
						$get="%$get%";
					}
					array_push($where_ands, "$field $operator '$get'");
				}
			}
		}
		$where= join(" and ", $where_ands);
		$count=$this->shiti_obj->where($where)->count();
		$page = $this->page($count, 10);
		$shiti=$this->shiti_obj->where($where)->limit($page->firstRow . ',' . $page->listRows)->order(array("id"=>"desc"))->select();
		foreach($shiti as $n=> $val){
			$shiti[$n]['stem']=htmlspecialchars_decode($val['stem']);
			$shiti[$n]['xa']=htmlspecialchars_decode($val['xa']);
			$shiti[$n]['xb']=htmlspecialchars_decode($val['xb']);
			$shiti[$n]['xc']=htmlspecialchars_decode($val['xc']);
			$shiti[$n]['xd']=htmlspecialchars_decode($val['xd']);
			$shiti[$n]['analysis']=htmlspecialchars_decode($val['analysis']);
		}  
		$this->assign('cs_id',$cs_id);
		$this->assign("Page", $page->show('Admin'));
		$this->assign('shiti',$shiti);
		$this->assign('count',$count);
		$this->display();
	}
	function  delshiti(){
		if(isset($_GET['id'])){
			$id = intval(I("get.id"));
			$res=$this->shiti_obj->where(array('id'=>$id))->delete();
			if($res){
				$this->success('删除成功！');
			}else{
				$this->error('删除失败！');
			}
		}
		if(isset($_POST['ids'])){
			$tids=join(",",$_POST['ids']);
			if ($this->shiti_obj->where("id in ($tids)")->delete()) {
				$this->success("删除成功！");
			} else {
				$this->error("删除失败！");
			}
		}
	}
	function  delshijuan(){
		if(isset($_GET['id'])){
			$id = intval(I("get.id"));
			$res=$this->papers_obj->where(array('id'=>$id))->delete();
			if($res){
                S('exam_data',null);
				$this->success('删除成功！');
			}else{
				$this->error('删除失败！');
			}
		}
		if(isset($_POST['ids'])){
			$tids=join(",",$_POST['ids']);
			if ($this->papers_obj->where("id in ($tids)")->delete()) {
                S('exam_data',null);
				$this->success("删除成功！");
			} else {
				$this->error("删除失败！");
			}
		}
	}
	
	function preview(){
		$id=  intval(I("get.id"));
		$type=  intval(I("get.type"));
		$data=$this->shiti_obj->where(array('id'=>$id))->find();
		$data['stem']=htmlspecialchars_decode($data['stem']);
		$data['xa']=htmlspecialchars_decode($data['xa']);
		$data['xb']=htmlspecialchars_decode($data['xb']);
		$data['xc']=htmlspecialchars_decode($data['xc']);
		$data['xd']=htmlspecialchars_decode($data['xd']);
		$data['analysis']=htmlspecialchars_decode($data['analysis']);
//		$data['daan']=strtoupper(htmlspecialchars_decode($data['daan']));
		$data['daan']=htmlspecialchars_decode($data['daan']);

		$daan=explode(',',$data['daan']);
		$this->assign('data',$data);
		$this->assign('daan',$daan);

		switch ($type)
			{
			case 1:
				$this->display('previewxuanze');
			  break;  
			case 2:
				$this->display('previewtiankong');
			  break;
		    case 3:
				$this->display('previewpan');
				break;
			case 4:
				$this->display('previewjieda');
				break;
			case 5:
				$this->display('previewchailiao');
			  break;
			case 6:
				$this->display('previewjieda');
				break;
			case 7:
				$this->display('previewxuanze');
				break;
			case 8:
				$this->display('previewjieda');
				break;
			case 9:
				$this->display('previewjieda');
				break;
			case 10:
				$this->display('previewjieda');
				break;
			case 11:
				$this->display('previewjieda');
				break;
			default:
			  $this->display('previewxuanze');
		   }
	}	
    function shijuan(){
		if(IS_POST){
			$where_ands=array("cs_id>0");
			$fields=array(
				'keyword'  => array("field"=>"title","operator"=>"like"),
		   );
			foreach ($fields as $param =>$val){
				if (isset($_POST[$param]) && !empty($_POST[$param])) {
					$operator=$val['operator'];
					$field   =$val['field'];
					$get=$_POST[$param];
					$_GET[$param]=$get;
					if($operator=="like"){
						$get="%$get%";
					}
					array_push($where_ands, "$field $operator '$get'");
				}
			}
		}
		$where= join(" and ", $where_ands);
		$count=$this->papers_obj->where($where)->count();
		$page = $this->page($count,10);
		$data=$this->papers_obj->where($where)->order(array('id'=>'desc'))->limit($page->firstRow . ',' . $page->listRows)->select();
		
		foreach($data as $v){
			$cs_id = $v['cs_id'];
			$course = M('course')->field("cs_name")->where("id = '$cs_id'")->find();
			$v['cs_id'] = $course['cs_name'];
			$a[] = $v;
		}
		$this->assign('data',$a);
		$this->assign("Page", $page->show('Admin'));
		$this->display();
	}
	
	//关闭试卷
	function closetestpaper(){
		$id=I("post.id");
		$data['state']=0;
		$save = M('exam_papers')->where(array('id'=>$id))->save($data);
		if($save){
			return json_encode($id);
		}
	}
	//开启试卷
	function opentestpaper(){
		$id=I("post.id");
		$data['state']=1;
		$save = M('exam_papers')->where(array('id'=>$id))->save($data);
		if($save){
			return json_encode($id);
		}
	}
	
	function paperspriew(){
		$id=I("get.id");
		$data=$this->papers_obj->where(array('id'=>$id))->find();
		$map1['id']=empty($data['single_choice_id'])?array("id"=>0 ):array('in',$data['single_choice_id']);
		$map2['id']=empty($data['fill_id'])?array("id"=>0):array('in',$data['fill_id']);
		$map3['id']=empty($data['determine_id'])?array("id"=>0 ):array('in',$data['determine_id']);
		$map4['id']=empty($data['essay_id'])?array("id"=>0):array('in',$data['essay_id']);
		$map5['id']=empty($data['material_id'])?array("id"=>0):array('in',$data['material_id']);
		$single_choice=$this->shiti_obj->where($map1)->select();
		$single_choice_num=$this->shiti_obj->where($map1)->count();
		
		$fill=$this->shiti_obj->where($map2)->select();
		$fill_num=$this->shiti_obj->where($map2)->count();
		
		$determine=$this->shiti_obj->where($map3)->select();
		$determine_num=$this->shiti_obj->where($map3)->count();
		
		$essay=$this->shiti_obj->where($map4)->select();
		$essay_num=$this->shiti_obj->where($map4)->count();
		
		$material=$this->shiti_obj->where($map5)->select();
		$material_num=$this->shiti_obj->where($map5)->count();
		$totalscore=$single_choice_num*$data['single_choice_score']+$fill_num*$data['fill_score']+$determine_num*$data['determine_score']+$essay_num*$data['essay_score']+$material_num*$data['material_score'];
		$this->assign('id',$id);
		$this->assign('data',$data);
		$this->assign('single_choice',$single_choice);
		$this->assign('fill',$fill);
		$this->assign('determine',$determine);
		$this->assign('essay',$essay);
		$this->assign('material',$material);
		$this->assign('single_choice_num',$single_choice_num);
		$this->assign('fill_num',$fill_num);
		$this->assign('determine_num',$determine_num);
		$this->assign('essay_num',$essay_num);
		$this->assign('material_num',$material_num);
		$this->assign('totalscore',$totalscore);
		$this->display();
	}

	
	function checkpaperfinished(){
		$id=I("get.cs_id");
		$teacherid=sp_get_current_userid();
		$count=$this->userpapers_obj->where(array('teacherid'=>$teacherid,'readover'=>1))->count();
		$page = $this->page($count, 10);
		$papers=$this->userpapers_obj->limit($page->firstRow . ',' . $page->listRows)->order(array("id"=>"desc"))->where(array('teacherid'=>$teacherid,'readover'=>1))->select();
		foreach($papers  as $n=> $val){
			$papers[$n]['title']= $this->papers_obj->where(array('id'=>$papers[$n]['papersid']))->getField('title');
		}
		$this->assign('papers',$papers);
		$this->assign("Page", $page->show('Admin'));
		$this->assign('cs_id',$id);
		$this->display();
	}
	
	function renyuan(){
		$id=I("get.id");
		$count=$this->userpapers_obj->where(array('papersid'=>$id))->count();
		$page = $this->page($count, 8);
		$users=$this->userpapers_obj->where(array('papersid'=>$id))->limit($page->firstRow . ',' . $page->listRows)->order(array("score"=>"desc"))->select();
		$this->assign('users',$users);
		$this->assign("Page", $page->show('Admin'));
		$this->display();
	}


	
}